﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Services;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    #region Email adresini username'e eşitleme
    protected void CreateUserWizard1_CreatingUser(object sender, EventArgs e)
    {
        CreateUserWizard1.Email = CreateUserWizard1.UserName;
    }
    #endregion

    #region kategori secmece
    protected void btnAddCategory_Click1(object sender, EventArgs e)
    {

        string cat1 = ddlistCat1.SelectedItem.Text;
        string cat2 = ddlistCat2.SelectedItem.Text;

        selectedCategories.InnerHtml = selectedCategories.InnerHtml + " <label>" + cat1 + ">>" + cat2 + "</label><img src='images/cancel.jpg' alt='cancel'></img>";

    }
    #endregion

    #region Üyelik olusturduktan sonra activation maili atma
    protected void CreateUserWizard1_SendingMail(object sender, System.Web.UI.WebControls.MailMessageEventArgs e) 
    {
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
        mailClient.EnableSsl = true;
        MembershipUser userInfo = Membership.GetUser(CreateUserWizard1.UserName);
        String verifyUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("~/activation.aspx?aId=" + userInfo.ProviderUserKey.ToString());
        e.Message.Body = e.Message.Body.Replace("<%VerifyUrl%>", verifyUrl);
        mailClient.Send(e.Message);
        e.Cancel = true;
    }
    #endregion

    #region Category Service page methodu
    [WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContentsPageMethod(string knownCategoryValues, string category)
    {
        return new CategoryService().GetDropDownContents(knownCategoryValues, category);
    }

    #endregion 

    #region User Olusturulup database e yazıldıgında calısır
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        // bu function da gerekli bilgileri kendi databasemize yazacaz.
        string a = "mahmut";
        MembershipUser myObject = Membership.GetUser(CreateUserWizard1.UserName);
        string UserID = myObject.ProviderUserKey.ToString();
    }
    #endregion
}
